package com.shj.em.biz.sys.controller;

import org.springframework.stereotype.Controller;

import java.util.List;
import java.util.Map;
import java.util.Arrays;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import com.shj.em.common.annotation.Log;
import com.shj.em.base.support.ResMsg;
import com.shj.em.base.vo.PageVO;

import com.shj.em.biz.sys.entity.Cd;
import com.shj.em.biz.sys.service.CdService;
import com.baomidou.mybatisplus.plugins.Page;
import lombok.extern.slf4j.Slf4j;


/**
 * <p>
 * 代码项值 前端控制器
 * </p>
 *
 * @author Shen Huang Jian
 * @since 2018-07-04
 */
@RestController
@Slf4j
@RequestMapping("/sys/cd")
public class CdController {

    @Autowired
    CdService cdService;

    @Log("创建代码项值")
    @PostMapping("/add")
    public ResMsg add(@RequestBody Cd cd){
        Long id = cdService.createCd(cd);
        return ResMsg.ok(id);
    }

    @Log("更新代码项值")
    @PostMapping("/save")
    public ResMsg save(@RequestBody Cd cd){
        cdService.updateCd(cd);
        return ResMsg.ok();
    }

    @Log("批量删除代码项")
    @PostMapping( "/batchRemove")
    public ResMsg batchRemove(@RequestBody Map<String, String> params){
        cdService.deleteBatchIds(Arrays.asList(params.get("ids").split(";")));
        return ResMsg.ok();
    }

}

